package com.c.ctgproject.ui.service

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.MyLog
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

class ServiceOrderListViewModel : BaseViewModel() {

    private val mResult = MutableLiveData<String>()
    val result: LiveData<String> get() = mResult
    /**所有不含修改的*/
    fun getAllOrder(search: String?, status: String?, orderSource: String?, page: Int) {
        MyLog.d("进来了么1")
        launch {
            mResult.value = ApiMethods.retrofit.serviceAllOrder(userToken, search, status, orderSource,  page, 20).awaitSync()
        }
    }
    /**意向订单*/
    fun serviceTalkOrder(search: String?,  orderSource: String?, page: Int){
        MyLog.d("进来了么2")
        launch {
            mResult.value = ApiMethods.retrofit.serviceTalkOrder(userToken,search,orderSource,page,20).awaitSync()
        }
    }
    /**预订单*/
    fun servicePreOrder(search: String?,  orderSource: String?, page: Int){
        MyLog.d("进来了么3")
        launch {
            mResult.value = ApiMethods.retrofit.servicePreOrder(userToken,search,orderSource,page,20).awaitSync()
        }
    }
}